#include "gofgame/jumpdown/sprite/TopSpike.h"
#include "gofgame/jumpdown/sprite/Hero.h"
#include "gofgame/jumpdown/util/objective-c.h"
#include "SimpleAudioEngine.h"
using namespace gofgame::jumpdown::sprite;
using namespace gofgame::jumpdown::util;
using namespace cocos2d;
using namespace CocosDenshion;

TopSpike::TopSpike(){

}
TopSpike::~TopSpike() {

}

bool TopSpike::init(){
	if(!CCSprite::init() || !this->initWithSpriteFrameName("top.png")) {
		delete this;
		return false;
	}
	this->setScale(CCDirector::sharedDirector()->getWinSize().width  / this->getContentSize().width);
	this->setColor(ccc3(255,0,0));
	return true;
}

TopSpike *TopSpike::createTopSpike(){
	TopSpike *topSpike;
	if(oc_new<TopSpike>(&topSpike)) {
		topSpike->autorelease();
	}
	return topSpike;
}

bool TopSpike::onTouchHero(Hero *hero) {
	SimpleAudioEngine::sharedEngine()->playEffect("g2nail.wav");
	hero->hurt();
	return true;
}